package client;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import rw.ReadWriteFile;
import phi.PhiN;
import method.*;
import traitement.Traitement;

public class Launch {

    private Launch() {
//        int n = 256;
//        calculate(n);
//        TablierGraph tablier = new TablierGraph(new Tablier(n));
// Tablier.affichage();
//        matrixform();
//        phin();
        phi(16);
    }

    private void phi(int n) {
        String file = "/home/me/Documents/ToWindows/Matrice/M" + n + ".txt";
        String matrixS = "";
        try {
            matrixS = ReadWriteFile.readFromFile(file);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Launch.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Launch.class.getName()).log(Level.SEVERE, null, ex);
        }
//        String result = new Traitement(matrixS).getResult();
        ReadWriteFile.writeTextToFile(matrixS, "/home/me/Documents/ToWindows/Matrice/phi" + n + ".txt");

    }

    private void calculate(int n) {
        CalculateMethod factors = new CalculateMethod(n);
        ReadWriteFile.writeTextToFile(factors.toMatrixText(), "/home/me/Documents/ToWindows/Matrice/M", n);

    }

    private void matrixform() {

        CalculateMethod factors;
        for (int entiermax = 2 ; entiermax <= 10 ; entiermax++) {
            factors = new CalculateMethod(entiermax);
            //System.out.println(factors.toText());
            ReadWriteFile.writeTextToFile(factors.toMatrixText(), "/home/me/Documents/ToWindows/interval/matrix" + entiermax + ".txt", entiermax);
        }

    }

    private void phin() {
        PhiN phi = new PhiN(512);
        System.out.println(phi);
        ReadWriteFile.writeTextToFile(phi.cptResult);
    }

    public static void main(String[] args) {
        new Launch();
    }
}
